package cn.com.xf.task;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import cn.com.xf.web.XFContainsTool;

import com.ibatis.sqlmap.client.SqlMapClient;

public class SqlMapClientTemplateManager {
	private static ThreadLocal<SqlMapClientTemplate> connectionHolder = new ThreadLocal<SqlMapClientTemplate>() {
		@Override
		public SqlMapClientTemplate initialValue() {
			Object o = XFContainsTool.getApplicationContext().getBean("sqlMapClient");
			SqlMapClientTemplate s = new SqlMapClientTemplate((SqlMapClient) o);
			return s;
		}
	};

	public static SqlMapClientTemplate getConnection() {
		return connectionHolder.get();
	}

	public static void init() {
		connectionHolder.get();
	}
}
